<?php
require(__META_CONTROLS_GEN__ . '/MeetingNoteMetaControlGen.class.php');

/**
 * This is a MetaControl customizable subclass, providing a QForm or QPanel access to event handlers
 * and QControls to perform the Create, Edit, and Delete functionality of the
 * MeetingNote class.  This code-generated class extends from
 * the generated MetaControl class, which contains all the basic elements to help a QPanel or QForm
 * display an HTML form that can manipulate a single MeetingNote object.
 *
 * To take advantage of some (or all) of these control objects, you
 * must create a new QForm or QPanel which instantiates a MeetingNoteMetaControl
 * class.
 *
 * This file is intended to be modified.  Subsequent code regenerations will NOT modify
 * or overwrite this file.
 *
 * @package My QCubed Application
 * @subpackage MetaControls
 */
class MeetingNoteMetaControl extends MeetingNoteMetaControlGen {
    // Initialize fields with default values from database definition
    /*
		public function __construct($objParentObject, MeetingNote $objMeetingNote) {
			parent::__construct($objParentObject,$objMeetingNote);
			if ( !$this->blnEditMode ){
				$this->objMeetingNote->Initialize();
			}
		}
    */
    public function calDate_Create($strControlId = null) {
        $this->calDate = new QCalendarPopup($this->objParentObject, $strControlId);
        $this->calDate->Name = QApplication::Translate('Date');
        //$this->calDate->DateTimePickerType = QDateTimePickerType::Date;
        if ($this->blnEditMode)
            $this->calDate->DateTime = $this->objMeetingNote->Date;
        else { //new
            $DefualtDate = new QDateTime();
            $DefualtDate->SetDate(date("Y"), date("m"), date("d"));
            $this->calDate->DateTime= $DefualtDate;
        }
        return $this->calDate;
    }




    protected $dttTime ;
    public function SaveMeetingNote() {
        try {
            $this->dttTime = new QDateTime();
            $this->dttTime->setDate (date("Y"), date("m"), date("d"));
            $this->dttTime->setTime (date("H"), date("i"), date("s"));
            //Get Current user
            $CurrentUser = $_SESSION['User']['Id'];
            //Should eUser
            $eUser = $_SESSION['User']['Id'];


            // Update any fields for controls that have been created
            $this->objMeetingNote->MeetingId = $_SESSION['MeetingId'];
            //if ($this->txtAttachmentId) $this->objMeetingNote->AttachmentId = $this->txtAttachmentId->Text;
            if ($this->calDate) $this->objMeetingNote->Date = $this->calDate->DateTime;
            if ($this->txtNotes) $this->objMeetingNote->Notes = $this->txtNotes->Text;
            if ($this->txtSubject) $this->objMeetingNote->Subject = $this->txtSubject->Text;
            if ($this->blnEditMode) {
                //*** Update
                $this->objMeetingNote->UpdateBy   = $CurrentUser;
                $this->objMeetingNote->UpdateDate = $this->dttTime;
            }
            else {
                //**** New
                $this->objMeetingNote->CreateBy   = $CurrentUser;
                $this->objMeetingNote->CreateDate = $this->dttTime;
            }
            // Update any UniqueReverseReferences (if any) for controls that have been created for it

            // Save the MeetingNote object
            $this->objMeetingNote->Save();

            // Finally, update any ManyToManyReferences (if any)
        } catch (QCallerException $objExc) {
            $objExc->IncrementOffset();
            throw $objExc;
        }
    }
}
?>